package learnjava.jvm;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.lang.management.BufferPoolMXBean;
import java.util.ArrayList;
import java.util.List;

public class TestStringTable {


    public static void main(String[] args) throws IOException {

        List<String> address = new ArrayList<>();
        System.in.read();
        for (int i = 0; i < 10; i++) {
            try (BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(
                    "E:\\黑马程序员\\资料 解密JVM\\代码\\jvm\\linux.words"), "utf-8"))) {
                String line = null;
                long start = System.nanoTime();
                while (true) {
                    line = reader.readLine();
                    if(line == null) {
                        break;
                    }
                    address.add(line);
                }
                System.out.println("cost:" +(System.nanoTime()-start)/1000000);
            }
        }
        System.in.read();
    }
//    public static void main(String[] args) {
//        //2743
////        String s1 = "a";
////        //2744
////        String s2 = "b";
////        String s3 = s1 + s2; //底层使用的是new StringBuilder,并调用toString返回一个new String
////        String s4 = "a" + "b"; //javac编译器自动把字符常量拼接了，然后去串池找已有的"ab"
////        String s5 = "ab";
////        System.out.println(s3==s5);
////        System.out.println(s4==s5);
//
////         String x1 = "ab";
//         String x2 = new String("a") + new String("b");
//         String x3 = x2.intern();
//         System.out.println(x2==x3);
//    }
}
